import { fliterPermission } from '@/utils/sys.js'
export const apis = {
  list: `/business/order/getList?modelCode=MODEL_ORDER&authCode=FUNCTION_ORDER_LIST`,
  del: `business/order/del?authCode=BTN_ORDER_DEL`,
  add: `business/order/inbound?authCode=BTN_ORDER_INBOUND`,
  edit: `business/order/inboundEdit?authCode=BTN_ORDER_EDIT`,
  detail: `business/order/detail?modelCode=MODEL_ORDER&authCode=BTN_ORDER_DETAIL`,
  outbound: `business/order/orderToTransfer?modelCode=MODEL_ORDER&authCode=BTN_ORDER_OUTBOUND`,
  state: `business/order/state?authCode=BTN_ORDER_STATE`,
  getUserList: `/business/user/getUserList?authCode=FUNCTION_ORDER_LIST`,
  getOrderList: `/business/order/getOrderList?authCode=BTN_ORDER_OUTBOUND`,
  getDefaultAddress: `/business/address/getDefaultAddress?authCode=BTN_ORDER_OUTBOUND`,
  getPrice: `/business/quotation/getPrice?authCode=BTN_ORDER_OUTBOUND`,
  getItems: `/business/items/getItems?authCode=BTN_ORDER_INBOUND`,
  getOrderDetail: `/business/order/getOrderDetail?modelCode=MODEL_ORDER&authCode=BTN_ORDER_INBOUND`,
};

export const configs = {
  listUrl: apis.list,
  pageOn: true, // 开启分页
  searchOn: true, // 开启搜索
  searchMode:'custome',
  operateOn: true, //开启操作区域
  treeOn: false, // 开启树形
};

export const searchs = [
  // {
  //   type: "SelectModel",
  //   column: "business_id",
  //   label: "商家",
  //   modelCode: "MODEL_BUSINESS",
  //   mapping : {
  //     label:['business_name'],
  //     value: 'id'
  //   }
  // },
  {
    type: "SelectModel",
    column: "user_id",
    label: "用户",
    url:apis.getUserList,
    mapping : {
      label:['user_nick'],
      value: 'id'
    },
    
   
  },
  {
    type: "SelectModel",
    column: "user_id",
    label: "用户编号",
    url:apis.getUserList,
    mapping : {
      label:['id','user_nick'],
      value: 'id'
    }
  },
  {
    type: "SelectModel",
    column: "order_transport_type",
    label: "包裹类型",
    modelCode: "MODEL_TRANSPORT_TYPE",
    mapping : {
      label:['transport_type_name'],
      value: 'id'
    }
  },
  {
    type: "Input",
    column: "order_no",
    label: "入库单号",
  },
  {
    type: "Input",
    column: "order_logistic_no",
    label: "快递单号",
  },
  {
    type: "Select",
    column: "order_state",
    label: "支付状态",
    dimCode: "DIM_TRANSFER_PAY_STATE"
  },
  {
    type: "Select",
    column: "order_state",
    label: "订单状态",
    dimCode: "DIM_ORDER_STATE"
  },
  
  {
    type: "DatePicker",
    column: "order_inbound_time",
    label: "入库时间",
  }
];

export const pages = {
  pageSize: 20,
  orders: [
    {
      field: "id",
      sort: "desc",
    },
  ],
 
};
export const columns = [
  { type: "selection" },
  // {
  //   label: "ID",
  //   column: "id",
  //   sortable: "custom",
    
  // },

  // {
  //   label: "商家",
  //   column: "business_id",
  //   display: "text",
  //   format:'model',
  //   config: {
  //     mode:'custom', //'default', 默认，custom自定义方式
  //     component: 'business/components/Mode',
  //   }
  // },
  {
    label: "用户",
    column: "user_id",
    display: "detail",
    format:'model',
    config: {
      mode:'custom', //'default', 默认，custom自定义方式
      component: 'user/components/Mode',
    }
  },
  {
    label: "入库单号",
    column: "order_no",
    display: "detail",
  },
  {
    label: "货架号",
    column: "order_shelf_no",
    display: "text",
  },
  {
    label: "快递单号",
    column: "order_logistic_no",
  },

  {
    label: "包裹类型",
    column: "order_transport_type",
    display: "text",
    format:'model',
  },
  {
    label: "包裹体积(m³)",
    column: "order_good_length",
    display: "text",
    slot:"volume",
     width:'120'
  },
  {
    label: "包裹长*宽*高(cm)",
    column: "order_good_length",
    slot: "tj",
    width:'160'
  },
  {
    label: "状态",
    column: "order_state",
    display: "state",
    format:'dim'
  },
  {
    label: "支付状态",
    column: "pay_state",
    display: "state",
    format:'dim'
  },
  {
    label: "入库时间",
    column: "order_inbound_time",
    format: "datetime",
    display: "text",
  },
  {
    label: "出库时间",
    column: "transfer_outbound_time",
    format: "datetime",
    display: "text",
  },
  { label: "操作", column: "operate", width: "240", fixed: "right" },
];

export const buttons = fliterPermission([
  {
    operate: "add",
    text: "入库",
    permission: 'BTN_ORDER_INBOUND',
    state: "all"
  },

  {
    operate: "outbound",
    text: "提交出库",
    permission: 'BTN_ORDER_OUTBOUND',
    state: "1"
  },


]);
export const columnButtons = fliterPermission([
  {
    operate: "detail",
    text: "详情",
    permission: 'BTN_ORDER_DETAIL',
  },
  // {
  //   operate: "outbound",
  //   text: "出库",
  //   permission: 'BTN_ORDER_OUT',
  // },
  {
    operate: "edit",
    text: "编辑",
    permission: 'BTN_ORDER_EDIT',
    hidden: ({ row })=> {
      if(['1'].includes(row.order_state)){
        return false
      }
      return true
    },
  }
 
]);
